home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / ascutils.zip / RMEXT.ASM < prev    next >
Assembly Source File  |  1988-05-20  |  1KB  |  96 lines

  1. PAGE 55,130
  2. ;                RMEXT
  3. ;
  4.  
  5. codeseg        segment
  6.         assume    cs:codeseg, ds:codeseg
  7.  
  8.         org    100h
  9.  
  10. rmext        proc    far
  11.  
  12. start:        jmp    Main
  13.  
  14. Main:        call    get_line
  15.         jc    Exit
  16.         call    fix_line
  17.         call    put_line
  18.         jmp    short Main
  19.  
  20. Exit:        int    020h
  21.  
  22. rmext        endp
  23.  
  24. ;        SUBROUTINE
  25. ;        sends line to std output
  26.  
  27. put_line    proc    near
  28.         mov    si,offset buffer
  29.         mov    dx,si
  30.         xor    cx,cx
  31. put_1:
  32.         inc    cx
  33.         lodsb
  34.         cmp    al,0Ah
  35.         jne    put_1
  36.         mov    bx,1
  37.         mov    ah,40h
  38.         int    21h
  39.         jc    put_line_ret
  40.         or    ax,ax
  41.         stc
  42.         jz    put_line_ret
  43.         clc
  44. put_line_ret:    ret
  45. put_line    endp
  46.  
  47.  
  48. ;        SUBROUTINE
  49. ;        inputs lines from std input
  50.  
  51. get_line    proc    near
  52.         mov    si,offset buffer
  53. get_1:        mov    dx,si
  54.         mov    cx,1
  55.         mov    bx,0
  56.         mov    ah,3Fh
  57.         int    21h
  58.         jc    get_line_ret
  59.         cmp    byte ptr [si],0Ah
  60.         je    get_line_ret
  61.         cmp    byte ptr [si],1Ah
  62.         stc
  63.         jz    get_line_ret
  64.         mov    cx,ax
  65.         jcxz    get_line_ret
  66.         inc    si
  67.         jmp    short get_1
  68. get_line_ret:    ret
  69. get_line    endp
  70.  
  71.  
  72. ;        SUBROUTINE
  73. ;        This routine looks for the period and moves eoln up to it.
  74.  
  75. fix_line    proc    near
  76.         sub    si,2
  77. fix_1:        cmp    byte ptr [si],2Eh
  78.         je    fix_2
  79.         cmp    byte ptr [si],5Ch
  80.         je    fix_line_ret
  81.         cmp    byte ptr [si],2Fh
  82.         je    fix_line_ret
  83.         dec    si
  84.         cmp    si,28Ah
  85.         je    fix_line_ret
  86.         jmp    short fix_1
  87. fix_2:        mov    byte ptr [si],0Dh
  88.         mov    byte ptr [si+1],0Ah
  89. fix_line_ret:    ret
  90. fix_line    endp
  91.  
  92. buffer        db    0
  93.  
  94. codeseg        ends
  95.         end    start
  96.